﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Net.Mail;
using System.Configuration;

namespace Koonsoft.Tool.SendMessage
{
    public class SendMail
    {
        public MailMessage BuildMail()
        {
            MailMessage mail = new MailMessage();
            mail.From = new MailAddress(ConfigurationManager.AppSettings["MyAddress"]);
            mail.To.Add(new MailAddress(ConfigurationManager.AppSettings["TargetAddress"]));
            mail.CC.Add(new MailAddress(ConfigurationManager.AppSettings["CC"]));
            mail.CC.Add(new MailAddress(ConfigurationManager.AppSettings["BCC"]));
            mail.Subject = "Test At " + DateTime.Now.ToString();
            mail.Body = "Only test ~";
            mail.SubjectEncoding = Encoding.UTF8;
            mail.IsBodyHtml = false;
            mail.Priority = MailPriority.High;


            return mail;
        }

        public SmtpClient BuildSmtpClient()
        {
            SmtpClient sender = new SmtpClient();
            sender.Host = "smtp.gmail.com";
            sender.Port = 587;
            sender.Credentials = new NetworkCredential("koonsoft@gmail.com", "notgiveup");
            sender.DeliveryMethod = SmtpDeliveryMethod.Network;
            sender.EnableSsl = true;

            return sender;
        }
    }
}
